home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / gfx / vtdevel3.lha / Include / iconstartup.i < prev   
Text File  |  1992-09-02  |  2KB  |  75 lines

  1. ;
  2. ; Iconstartup.i
  3. ;
  4. ; include this to allow startup from icon.
  5. ; Just code the rest of your program as if you were writing for CLI.
  6. ;
  7. ; You should also add these lines to your code:
  8. ;
  9. ;    include "exec/exec_lib.i"
  10. ;    include    "exec/exec.i"
  11. ;    include    "libraries/dosextens.i
  12. ;
  13. ; or similar code for your assembler...
  14. ;
  15. ; If your assembler won't assemble this, throw it away and buy
  16. ; the excellent HISOFT DEVPAC 3.0 from Hisoft Software.
  17.  
  18.  
  19.     movem.l    d0/a0,-(sp)
  20.  
  21.     sub.l    a1,a1
  22.     move.l  4.w,a6
  23.     jsr    _LVOFindTask(a6)
  24.  
  25. ; Could use ThisTask(a6) here, but we won't. The general rule
  26. ; is that if there is a system function to read a structure, use
  27. ; that rather than peeking the structure directly. This gives
  28. ; Commodore greater freedom to change things in the future...
  29.  
  30.     move.l    d0,a4
  31.  
  32.     tst.l    pr_CLI(a4)    ; was it called from CLI?
  33.     bne.s   fromCLI        ; if so, skip out this bit...
  34.  
  35.     lea    pr_MsgPort(a4),a0
  36.     move.l  4.w,a6
  37.     jsr    _LVOWaitPort(A6)
  38.     lea    pr_MsgPort(a4),a0
  39.     jsr    _LVOGetMsg(A6)
  40.     move.l    d0,returnMsg
  41.  
  42. fromCLI
  43.     movem.l    (sp)+,d0/a0
  44.  
  45. go_program
  46.  
  47.  
  48.     bsr.s    _main               ; Calls your code..
  49.  
  50. ; If your code does not allow exit, the following lines are
  51. ; not required
  52.  
  53.     move.l    d0,-(sp)
  54.  
  55.     tst.l    returnMsg        ; Is there a message?
  56.     beq.s    exitToDOS        ; if not, skip...
  57.  
  58.     move.l    4.w,a6
  59.         jsr    _LVOForbid(a6)          ; note! No Permit needed!
  60.  
  61.     move.l    returnMsg(pc),a1
  62.     jsr    _LVOReplyMsg(a6)
  63.  
  64. exitToDOS
  65.     move.l    (sp)+,d0        ; exit code
  66.     rts
  67.  
  68. ; These next lines are required whether you want to exit or not!
  69.  
  70.  
  71. returnMsg dc.l    0
  72.  
  73.     even                ;(or cnop 0,2)
  74. _main
  75.